//
//  UnderlineButton.m
//  JiuLe
//
//  Created by 黄鑫 on 16/8/26.
//  Copyright © 2016年 Fine. All rights reserved.
//

#import "UnderlineButton.h"

@implementation UnderlineButton
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if (self) {
        NSMutableAttributedString *titl = [[NSMutableAttributedString alloc] initWithString:self.titleLabel.text];
        NSRange regtitleRange = {0,[titl length]};
        [titl addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:regtitleRange];
        [titl addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:166/255.0 green:167/255.0 blue:168/255.0 alpha:1.0] range:regtitleRange];
        [titl addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:11.0f] range:regtitleRange];
        [self setAttributedTitle:titl
                        forState:UIControlStateNormal];
    }
    return self;
}

- (void)setUnderLine:(NSString *)title{
    NSMutableAttributedString *titl = [[NSMutableAttributedString alloc] initWithString:title];
    NSRange regtitleRange = {0,[titl length]};
    [titl addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:regtitleRange];
    [titl addAttribute:NSForegroundColorAttributeName value:[UIColor grayColor] range:regtitleRange];
    [titl addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:11.0f] range:regtitleRange];
    [self setAttributedTitle:titl
                    forState:UIControlStateNormal];
}
@end
